import math
class Solution(object):
    def rangeBitwiseAnd(self, left, right):
        """
        :type left: int
        :type right: int
        :rtype: int
        """
        diff = right - left
        base = 2 ** 31 - 1
        if diff != 0:
            wei = int(math.log2(diff))
            for i in range(wei + 1):
                base -= 2 ** i
        return base & left & right


data = Solution()
left = 1
right = 2147483647
print(data.rangeBitwiseAnd(left, right))
